package com.zjw.server.controller;

import com.zjw.model.R;
import com.zjw.model.enums.ClientType;
import com.zjw.model.pojo.vo.MessageVO;
import com.zjw.server.service.MessageService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Set;

@RestController
@RequestMapping("/server")
public class MessageController {


    @Resource
    private MessageService messageService;

    /**
     * 发送消息给指定用户所有客户端
     *
     * @param message
     * @return
     */
    @PostMapping("/sendMessageToUser")
    public R<Set<ClientType>> sendMessageToUser(@RequestBody MessageVO message) {
        return messageService.sendMessageToUser(message);
    }

    /**
     * 发送消息给指定用户指定客户端类型
     *
     * @param message
     * @return
     */
    @PostMapping("/sendMessageToClientType")
    public R<Set<ClientType>> sendMessageToClientType(@RequestBody MessageVO message) {
        return messageService.sendMessageToClientType(message);
    }
}
